﻿using System.Xml;
using System.Xml.Linq;

namespace System.Modules.Extensions
{
    /// <summary>
    /// Xml Node Extensions
    /// </summary>
    public static class XmlNodeExtensions
    {
        /// <summary>
        /// To X Element
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static XElement ToXElement(this XmlNode node)
        {
            var xDoc = new XDocument();
            if (node != null)
            {
                using (var xmlWriter = xDoc.CreateWriter())
                {
                    node.WriteTo(xmlWriter);
                }
            }
            return xDoc.Root;

        }
    }
}
